package org.eCon.maven.plugin.windows;

import org.eCon.maven.plugin.AbstractGWTRunPlugin;

import java.io.File;

/**
 * User: erkink
 * Date: 14-Aug-2008
 * Time: 19:55:22
 */
public class WindowsGWTRunPlugin extends AbstractGWTRunPlugin {
    public WindowsGWTRunPlugin() {
        this.cpDelimiter = WindowsHelper.getCpDelimiter();
    }

    protected String getEnvLib() {
        return WindowsHelper.getEnvLib();
    }

    public void createHostModeScript() {

        StringBuffer sb = new StringBuffer(200);
        sb.append(createJavaPath());
        sb.append(this.getJVMParam());
        sb.append(" -cp ");
        sb.append(this.getClasspath());
        sb.append("  ");
        sb.append(SHELL);
        sb.append(" ");

        sb.append(" %* ");
        this.controlAndAppend(this.gwt_relative_out, "out", sb, true);
        sb.append(this.gwt_module).append("/").append(getHtmlName(this.gwt_module));

        String cmd = WindowsHelper.convertWinPath(sb.toString());
        cmd = "@" + cmd;

        String filePath = new StringBuffer(100).append(this.currentDir).append(File.separator).
                append("gwt-shell.cmd").toString();

        this.writeToFile(WindowsHelper.convertWinPath(filePath), cmd);
    }

    protected String getJVMParam() {
        return " -Xmx256M ";
    }

}
